// scripts.js
document.addEventListener('DOMContentLoaded', () => {
    const navLinks = document.querySelectorAll('nav a');
    const dots = document.querySelectorAll('.dot');

    navLinks.forEach(link => {
        link.addEventListener('click', () => {
            navLinks.forEach(link => link.classList.remove('active'));
            link.classList.add('active');
        });
    });

    let slideIndex = 0;
    showSlides();

    function showSlides() {
        const slides = document.querySelectorAll('.mySlides');
        for (let i = 0; i < slides.length; i++) {
            slides[i].style.display = "none";
        }
        slideIndex++;
        if (slideIndex > slides.length) {slideIndex = 1}
        for (let i = 0; i < dots.length; i++) {
            dots[i].classList.remove('active-dot');
        }
        slides[slideIndex - 1].style.display = "block";
        dots[slideIndex - 1].classList.add('active-dot');
        setTimeout(showSlides, 3000); // 切换时间间隔为 3 秒
    }
});

